﻿#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "scene.h"
#include "ctrlboard.h"
#include "mg_Device.h"
#include "mg_Lcd_Driver.h"
#define ITU_PLAY_VIDEO_ON_BOOTING

static ITULayer* touchCalibrationLayer;
static ITUVideo *Video_boot = 0;

static void LogoVideoOnStop(ITUVideo* video)
{
	if (MessageFlag[MSG_RS485_EN] == OFF)
	{
		MessageFlag[MSG_RS485_EN] = ON;
	}
	GotoMainMenu();
}
bool LogoOnEnter(ITUWidget* widget, char* param)
{
#ifdef WIN32
	GotoMainMenu();
#else
#ifdef ITU_PLAY_VIDEO_ON_BOOTING
	if (!Video_boot)
	{
		Video_boot = ituSceneFindWidget(&theScene, "Video_boot");
		assert(Video_boot);
	}
	ituVideoPlay(Video_boot, 0);
	ituVideoSetOnStop(Video_boot, LogoVideoOnStop);
#else
		GotoMainMenu();
#endif
#endif
    return true;
}
bool LogoOnTimer(ITUWidget* widget, char* param)
{
	static bool BackOnOff = false;
	static uint16_t BackDelay = 0;
	BackDelay++;
	//背光打开延迟，防止显示上电后的乱内存
	if (BackOnOff == false && BackDelay >= 20)
	{
		BackOnOff = true;
		ioctl(ITP_DEVICE_BACKLIGHT, ITP_IOCTL_ON, NULL);
	}
}
void LogoReset(void)
{
    touchCalibrationLayer = NULL;
}